<div class="create-ticket">
<div class="create-ticket-atas">Update Ticket</div>
<div class="create-ticket-tengah">
<div align="right" class="notif"></div>
<?php if((isset($_SESSION['sys_admin']))||(isset($_SESSION['admin']))||(isset($_SESSION['intern_audit']))||(isset($_SESSION['second_consult']))||(isset($_SESSION['dept_pic']))) {?>
<script type="text/javascript" src="<?php echo base_url();?>lighbox/js/jquery.lightbox-0.5.js"></script>
 <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>lighbox/css/jquery.lightbox-0.5.css" media="screen" />

<style type="text/css">
.merah {
	background:#FFCCFF;
	}
.high {
	background:#FF3300;
	}
.medium {
	background:#FFCC66;
	}
.low {
	background:#FFFF00;
	}
.note {
	background:#33CC33;
	}
#tombol {
 margin-right: 10px;
 cursor: pointer;
}
#hidden_div {
 display:none;
 text-align: left;    
 z-index: 99999;
 padding: 0;
 width: 650px;
 margin-top: 5px;
 font-size: 10px;
}
.cmnt {
		width:auto;
		height:auto;
		padding-top:10px;
		padding-left:5px;
		padding-right:0px;
		padding-bottom:5px;
		border:1px solid #CCCCCC;
		
		-moz-border-radius:5px;
		}
	.cmnt table tr td {
		border:none;
		}
	.cmnt a {
		color:#000099;
		}
/* jQuery lightBox plugin - Gallery style */
	#gallery {
		background-color:;
		padding: 0px;
		width: 80px;
		float:left;
		margin-top:-10px;
		
		
	}
	#gallery ul { list-style: none; }
	#gallery ul li { display: inline; }
	#gallery ul img {
		border: 5px solid #3e3e3e;
		border-width: 5px 5px 10px;
		margin-left:-40px;
	}
	#gallery ul a:hover img {
		border: 5px solid #fff;
		border-width: 5px 5px 10px;
		color: #fff;
	}
	#gallery ul a:hover { color: #fff; }
	.s {
		display:none;
		}
/* Comments
----------------------------------------------------*/
.cmnt-box {
	width:550px;
	height:auto;
	
	float:right;
	padding-left:0px;
	background:#ffffff;
	margin-left:10px;
	-moz-border-radius:5px;
	}
.cmnt-isi {
	width:535px;
	height:15px;
	padding:5px;
	padding-left:10px;
	height:auto;
	background:#ffffff;
	-moz-border-radius-topleft:5px;
	-moz-border-radius-topright:5px;
	}
	.cmnt-isi a {
		color:#003399;
		font-size:14px;
		
		}
	.cmnt-isi-2 {
		width:520px;
		height:auto;
		background:#ffffff;
		margin-left:10px;
		margin-top:5px;
		margin-bottom:5px;
		padding:5px;
		-moz-border-radius:5px;
		}
.cmnt-box2 {
	width:450px;
	height:auto;
	padding-bottom:15px;
	float:left;
	padding-left:10px;
	background:#FFCC99;
	margin-left:110px;
	}
.cmnt-box-utama {
	width:650px;
	height:auto;
	float:left;
	padding-bottom:10px;
	background:#ebebeb;
	margin-bottom:10px;
	padding:10px;
	-moz-border-radius:5px;
	}


/* end Comments
----------------------------------------------------*/
</style>

<script type="text/javascript">
function add_file_field(){
var container=document.getElementById('file_container');
var file_field=document.createElement('input');
file_field.name='images[]';
file_field.type='file';
container.appendChild(file_field);
var br_field=document.createElement('br');
container.appendChild(br_field);

}

$(document).ready(function(){
 $("#tombol").click(function () {
 $("#hidden_div:visible").hide("slow");
 });
 $("#tombol").click(function () {
 $("#hidden_div:hidden").show("slow");
 });

 });

$(function() {
        $('#gallery a').lightBox();
    });

</script>
<?php

//----------------------
if(isset($severitys) == "Critical") {
	$target_date = " 1 day";
	$cl ="merah";
} else if(isset($severitys) == "High") {
	$target_date = " 2 day";
	$cl="high";
} else if(isset($severitys) == "Medium") {
	$target_date = "5 day";
	$cl="medium";
} else if(isset($severitys) == "Low"){
	$target_date = "7 day";
	$cl="low";
} else if(isset($severitys) == "Note"){
	$target_date = "9 day";
	$cl="note";
} else {
	
}

?>
<?php
if($change == $ticket_id) {
	$a = "";
}else {
	$a ="disabled";
}

if(isset($probs)) {
	$pro = $probs;
	} else {
		$pro = $prob;
		}
if(isset($levels)) {
	$lev = $levels;
	} else {
		$lev=$level;
		}

if(isset($ticket_ids)) {
	$tic = $ticket_ids;
	}else {
		$tic = $ticket_id;
		}
?>

<h2><?php echo $h2_title;?></h2>
<?php
echo ! empty($message) ? '<p class="message">' . $message . '</p>': '';

	$flashmessage = $this->session->flashdata('message');
	echo ! empty($flashmessage) ? '<p class="message">' . $flashmessage . '</p>': '';
?>
<form action="<?php echo site_url('createticket/mngticket/update_process');?>" method="post" name="kirim" enctype="multipart/form-data">
<input type="hidden" name="images1" value="<?php if(isset($images1s)) {echo $images1s;}else {echo $images1;} ?>" />
<input type="hidden" name="images2" value="<?php if(isset($images2s)) {echo $images2s;}else {echo $images2;} ?>" />
<input type="hidden" name="images3" value="<?php if(isset($images1s)) {echo $images3s;}else {echo $images3;} ?>" />
<input type="hidden" name="images4" value="<?php if(isset($images1s)) {echo $images4s;}else {echo $images4;} ?>" />
<input type="hidden" name="images5" value="<?php if(isset($images1s)) {echo $images5s;}else {echo $images5;} ?>" />
<input type="hidden" name="images6" value="<?php if(isset($images1s)) {echo $images6s;}else {echo $images6;} ?>" />
<input type="hidden" name="images7" value="<?php if(isset($images1s)) {echo $images7s;}else {echo $images7;} ?>" />
<input type="hidden" name="images8" value="<?php if(isset($images1s)) {echo $images8s;}else {echo $images8;} ?>" />
<input type="hidden" name="images9" value="<?php if(isset($images1s)) {echo $images9s;}else {echo $images9;} ?>" />
<input type="hidden" name="images10" value="<?php if(isset($images1s)) {echo $images10s;}else {echo $images10;} ?>" />
<table>
	<tr>
    	<td>ID</td><td>:</td><td>
        
        <input type="text" name="ticket_id" disabled="disabled" value="<?php if(isset($ticket_ids)) {echo $ticket_ids;} else { echo $ticket_id;}?>" />
        <input type="hidden" name="ticket_id"  value="<?php if(isset($ticket_ids)) {echo $ticket_ids;} else { echo $ticket_id;}?>" />
		</td><td></td><td></td>
    </tr>
    <tr>
    	<td>Title</td><td>:</td><td><input type="text" name="title"  value="<?php if(isset($titled)) { echo $titled;} else { echo $title;}?>"/>&nbsp;</td><td></td><td><?php echo form_error('title', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Reference ID</td><td>:</td><td><input type="text" name="reference_id"  value="<?php if(isset($references)) {echo $references;} else { echo $reference;}?>"  />
        	&nbsp;&nbsp;<a href="Javascript:openWindowRef('<?php echo site_url('createticket/ticket/search_reference/'.isset($user_ids).$user_id);?>')"><img src="<?php echo base_url();?>images/11.png" alt="Search Reference Id" width="16" height="16" align="absmiddle" border="0" /> &nbsp;Search</a>
        </td><td></td><td></td>
    </tr>
	<tr>
    	<td>Vulnerability Detail</td><td>:</td><td>
        </td><td></td>
    </tr>

    <tr>
    	<td></td><td></td><td><textarea name="vul_detail" rows="20" class="tinymce"><?php if(isset($vul_dets)) { echo htmlentities($vul_dets);} else { echo htmlentities($vul_det);}?></textarea></td><td>&nbsp;&nbsp;</td><td><?php echo form_error('vul_detail', '<i class="field_error">', '</i>');?></td>
    </tr>
	<tr>
    	<td>Vulnerability Solution</td><td>:</td><td>
        </td><td></td>
    </tr>

    <tr>
    	<td></td><td></td><td><textarea name="sol_detail" rows="20" class="tinymce"><?php if(isset($vul_sols)){ echo htmlentities($vul_sols);} else { echo htmlentities($vul_sol);}?></textarea></td><td>&nbsp;&nbsp;</td><td><?php echo form_error('sol_detail', '<i class="field_error">', '</i>');?></td>
    </tr>
	<tr>
    	<td>Impact</td><td>:</td><td>
        </td><td></td>
    </tr>
    <tr>
    	<td></td><td></td><td><textarea name="impact_detail" rows="20" class="tinymce"><?php if(isset($impacts)) { echo htmlentities($impacts);} else {echo htmlentities($impact);}?></textarea></td><td></td><td><?php echo form_error('impact_detail', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Open Datetime</td><td>:</td><td><input type="text" name="open_date" disabled="disabled" value="<?php if(isset($open_dates)) {echo $open_dates;} else {echo $open_date;}?>"/>
        <input type="hidden" name="open_datetime"  value="<?php if(isset($open_dates)) {echo $open_dates;} else {echo $open_date;}?>"/>&nbsp;&nbsp;
        </td><td></td><td><?php echo form_error('open_datetime', '<i class="field_error">', '</i>');?></td>
    </tr>

    <tr>
    	<td>Probaility Of Impact</td><td>:</td><td>
        	
        	<select name="prob_o_impact" class="fg" id="prob_o_impact">
            	<option value=""></option>
            	<option value="3" class="opt1" <?php if($pro == "3") echo "selected";?> ><span>High</span></option>
                <option value="2" class="opt2" <?php if($pro == "2") echo "selected";?>>Medium</option>
                <option value="1" class="opt3" <?php if($pro == "1") echo "selected";?>>Low</option>
                
            </select>&nbsp;&nbsp;
        </td><td></td><td><?php echo form_error('prob_o_impact', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Level Of Impact</td><td>:</td><td>
        	<select name="level_o_impact" class="fg" id="level_o_impact">
            	<option value=""></option>
            	<option value="3" class="opt1" <?php if($lev == "3") echo "selected";?> ><span>High</span></option>
                <option value="2" class="opt2" <?php if($lev == "2") echo "selected";?>>Medium</option>
                <option value="1" class="opt3" <?php if($lev == "1") echo "selected";?>>Low</option>
                
            </select>&nbsp;&nbsp;
        </td><td></td><td><?php echo form_error('level_o_impact', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Severity Level</td><td>:</td><td><input type="text" name="severity" disabled="disabled" value="<?php if(isset($severitys)) {echo $severitys;}else {echo $severity;}?>" class="<?php echo $cl;?>" class="cb" id="severity" />
        	<input type="hidden" name="severity_level"  value="<?php if(isset($severitys)) {echo $severitys;}else {echo $severity;}?>" />&nbsp;&nbsp;
        </td><td></td><td><?php echo form_error('severity_level', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Target Date</td><td>:</td><td>
		<select name="target_date" class="fg" <?php echo $a;?> id="target">
			<option value="1 day" <?php if($severitys == "Critical") { echo "selected";} ?>>1 day</option>
			<option value="2 day" <?php if($severitys == "High") { echo "selected";} ?>>2 day</option>
			<option value="5 day" <?php if($severitys == "Medium") { echo "selected";} ?>>5 day</option>
			<option value="7 day" <?php if($severitys == "Low") { echo "selected";} ?>>7 day</option>
			<option value="9 day" <?php if($severitys == "Note") { echo "selected";} ?>>9 day</option>
		</select>

		&nbsp;<a href="Javascript:openWindow('<?php echo site_url('createticket/mngticket/coments2/'.$tic);?>')"><img src="<?php echo base_url();?>images/12.png" alt="Tambah Data" width="16" height="16" align="absmiddle" border="0" /> &nbsp;Change target date</a> &nbsp;&nbsp;</td><td></td><td><?php echo form_error('target_date', '<i class="field_error">', '</i>');?></td>
    </tr>
     <tr>
    	<td>Product</td><td>:</td><td>
        	<select name="prod_id" class="fg">
            	<option value=""></option>
            	<?php foreach($prod->result() as $prod) :?>
            	<option value="<?php echo $prod->prod_id;?>" <?php if(isset($products) == $prod->prod_id) echo "selected";elseif($product == $prod->prod_id) echo "selected";?>><?php echo $prod->product;?></option>
                <?php endforeach;?>

                
            </select>&nbsp;&nbsp;
        </td><td></td><td><?php echo form_error('prod_id', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Close Date Time</td><td>:</td><td><input type="text" name="close_date" disabled="disabled" value="<?php if(isset($close_dates)) {echo $close_dates;} else {echo $close_date;}?>" />
        	<input type="hidden" name="close_date" value="" />
        </td><td></td><td></td>
    </tr>
    <tr>
    	<td>User</td><td>:</td><td><input type="text" name="user_id" disabled="disabled"  value="<?php if(isset($names)){echo $names;} else {echo $name;}?>"/>
        	<input type="hidden" name="user_id"  value="<?php if(isset($user_ids)) {echo $user_ids;}else {echo  $user_id;}?>"/>
            <input type="hidden" name="user_id2"  value="<?php if(isset($names)){echo $names;} else {echo $name;}?>"/>&nbsp;&nbsp;*<i>wajib di isi</i>
        </td><td></td><td><?php echo form_error('user_id', '<i class="field_error">', '</i>');?></td>
    </tr>
    <tr>
    	<td>Status</td><td>:</td><td><input type="text" name="status" disabled="disabled" value="<?php if(isset($statuss)){echo $statuss;} else {echo $status;}?>" />
        	<input type="hidden" name="status" value="<?php if(isset($statuss)){echo $statuss;} else {echo $status;}?>"  />
        </td><td></td><td></td>
    </tr>
</table>
<div class="cmnt">
<table>
    <tr>
    	<td>Coments</td><td>:</td><td></td><td></td><td></td>
    </tr>
	<tr>
    	<td></td><td>&nbsp;</td><td>
			<a id="tombol">Show All Comments Click Here</a>
			<div id="hidden_div">
			<div>Create Coments if your want complete and perhap thats</div>
					 <div class="cmnt-box-utama">
						<?php
						$ref =$ticket_ids; 
						$am =mysql_query("select a.*,b.* from comments2 a,user b where a.user_id = b.user_id and ticket_id ='$ref' order by id asc limit 1");
						if($av = mysql_fetch_array($am)) {
						?>
						<div id="gallery">
							<ul>
								<?php if($av['images2']) { ?>
								<li>
								 <a href="<?php echo base_url();?>uploads/<?php echo $av['images1'];?>" title=""><img src="<?php echo base_url();?>uploads/<?php echo $av['images1'];?>" width="72" height="72" alt="" /> </a>
								</li>
								<?php }?>
								<?php if($av['images2']) { ?>
									<li>
										<a href="<?php echo base_url();?>uploads/<?php echo $av['images2'];?>" title=""></a>
									</li>
								<?php }?>
								<?php if($av['images3']) { ?>
									<li>
										<a href="<?php echo base_url();?>uploads/<?php echo $av['images3'];?>" title=""></a>
									</li>
								<?php }?>
								<?php if($av['images4']) { ?>
									<li>
										<a href="<?php echo base_url();?>uploads/<?php echo $av['images4'];?>" title=""></a>
									</li>
								<?php }?>
								<?php if($av['images5']) { ?>
									<li>
										<a href="<?php echo base_url();?>uploads/<?php echo $av['images5'];?>" title=""></a>
									</li>
								<?php }?>
																
							</ul>
						</div>
						
						
							<div class="cmnt-box">
							<div class="cmnt-isi">
							<a href="Javascript:openWindowRef('<?php echo site_url('createticket/mngticket/update_comments/'.$av['id']);?>')"><?php echo $av['name'];?> </a>&nbsp;&nbsp;>>&nbsp;&nbsp;<i><b> <?php echo $av['tanggal'];?></b></i>
							</div>
							<div class="cmnt-isi-2">
							<?php echo $av['notes'];?><br />
								<!--<a href=""><img src="<?php echo base_url();?>images/1.png" /></a>-->							</div>
						
							</div>
						<?php } ?>
						
							
						
					</div>
					<?php
						
						$ref2 =$av['id'];
						 
						$ref3 =$av['ticket_id'];
						$b =mysql_query("select a.*,b.* from comments2 a,user b where a.user_id = b.user_id and ticket_id ='$ref'  and id !='$ref2' order by id desc") or die(mysql_error());
						while($ab = mysql_fetch_array($b)) {
						
						?>
					<div class="cmnt-box-utama">
						
						<div id="gallery">
							<ul>
								<li>
								 <a href="<?php echo base_url();?>uploads/<?php echo $ab['images1'];?>" title=""><img src="<?php echo base_url();?>uploads/<?php echo $ab['images1'];?>" width="72" height="72" alt="" /> </a>
								 
								</li>
								<?php if($ab['images2']) {?>
								<li>
										<a href="<?php echo base_url();?>uploads/<?php echo $ab['images2'];?>" title=""></a>
									</li>
								<?php } ?>
								<?php if($ab['images3']) {?>
								<li>
										<a href="<?php echo base_url();?>uploads/<?php echo $ab['images3'];?>" title=""></a>
									</li>
								<?php } ?>
								<?php if($ab['images4']) {?>
								<li>
										<a href="<?php echo base_url();?>uploads/<?php echo $ab['images4'];?>" title=""></a>
									</li>
								<?php } ?>
								<?php if($ab['images5']) {?>
								<li>
										<a href="<?php echo base_url();?>uploads/<?php echo $ab['images5'];?>" title=""></a>
									</li>
								<?php } ?>
								
							</ul>
						</div>
						
						
							<div class="cmnt-box">
							<div class="cmnt-isi">
							<a href="Javascript:openWindowRef('<?php echo site_url('createticket/mngticket/update_comments/'.$ab['id']);?>')"><?php echo $ab['name'];?></a> &nbsp;&nbsp;>>&nbsp;&nbsp;<i><b> <?php echo $ab['tanggal'];?></b></i>
							</div>
							<div class="cmnt-isi-2">
							<?php echo $ab['notes'];?>
							</div>
							</div>
						
					</div>
					<?php } ?>

			</div>

		</td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td></td><td>
		<input type="hidden" name="tanggal" value="<?php echo date('d-m-Y H:i');?>"/>
		<input type="hidden" name="id" value="<?php echo $idcmnt2;?>" />
		<input type="hidden" name="ticket_id" value="<?php echo $ticket_ids;?>" />
		<input type="hidden" name="user_id" value="<?php if(isset($user_ids)) {echo $user_ids;}else {echo  $user_id;}?>" />
		<textarea name="notes" cols="25" rows="20" class="tinymce"><?php if(isset($comentss)){echo $comentss;}else {echo $coments;}?></textarea>
        </td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td>&nbsp;</td><td></td><td></td><td></td>
    </tr>
    <tr>
    	<td>Create Image</td><td>:</td><td></td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td></td><td><div id="file_container">
    <input name="images[]" type="file"  /><br />
    
  </div><a href="javascript:void(0);" onClick="add_file_field();">Add another</a>
</td><td></td><td></td>
    </tr>
    
    <tr>
    	<td></td><td>&nbsp;</td><td></td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td>&nbsp;</td><td><input type="submit" value="Save" name="kirim" /> &nbsp;&nbsp;<input type="reset" value="Cancel" /></td><td></td><td></td>
    </tr>
    <tr>
    	<td></td><td>&nbsp;</td><td></td><td></td><td></td>
    </tr>
</table>
</div>
    </form>
<?php } ?>

<script language="javascript">
$('#prob_o_impact').change(function(){
	/*$.post("<?php //echo base_url();?>index.php/createticket/ticket/get_value/"+$('#prob_o_impact').val(),{data1:$('#prob_o_impact').val()},
		function(o){
			$('#severity').html(o);
		}
	);*/
	calc_sev();
	if($('#severity').val() =='Note') {
		$('#target').val('9 day');

	}else if($('#severity').val() =='Low') {
		$('#target').val('7 day');
	}else if($('#severity').val() =='Medium') {
		$('#target').val('5 day');
	}else if($('#severity').val() =='High') {
		$('#target').val('2 day');
	}else if($('#severity').val() =='Critical') {
		$('#target').val('1 day');
	}
	 else {
		$('#target').val('');
	}
	
});
$('#level_o_impact').change(function(){
 	calc_sev();
	if($('#severity').val() =='Note') {
		$('#target').val('9 day');

	}else if($('#severity').val() =='Low') {
		$('#target').val('7 day');
	}else if($('#severity').val() =='Medium') {
		$('#target').val('5 day');
	}else if($('#severity').val() =='High') {
		$('#target').val('2 day');
	}else if($('#severity').val() =='Critical') {
		$('#target').val('1 day');
	}
	 else {
		$('#target').val('');
	}



});


function calc_sev(){
	/*$('#severity').val($('#prob_o_impact').val() * $('#level_o_impact').val());*/
	if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==1) {	
		$('#severity').val('Note');
		$('.cb').css("background-color","#FFCCFF");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==2) {
		$('#severity').val('Low');
		$('.cb').css("background-color","#FFFF00");

	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==3) {
		$('#severity').val('Medium');
		$('.cb').css("background-color","#FFCC66");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==4) {
		$('#severity').val('Medium');
		$('.cb').css("background-color","#FFCC66");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==6) {
		$('#severity').val('High');
		$('.cb').css("background-color","#FF3300");
	}else if(($('#prob_o_impact').val() * $('#level_o_impact').val()) ==9) {
		$('#severity').val('Critical');
		$('.cb').css("background-color","#ff0000");
	}
}
/*function target_date() {
	if($('#severity').val('Note')) {
		$('#target').val('9 day');
	}else if($('#severity').val('Low')) {
		$('#target').val('7 day');
	}else if($('#severity').val('Medium')) {
		$('#target').val('5 day');
	}else if($('#severity').val('High')) {
		$('#target').val('2 day');
	}else if($('#severity').val('Critical')) {
		$('#target').val('1 day');
	}
}*/

</script>
</div>
<div class="create-ticket-bawah"></div>
</div>
